/**
 * 
 */
package com.lanswon.qzsmk.listener;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

import ch.qos.logback.classic.Logger;

import com.lanswon.qzsmk.base.CardContants;
import com.lanswon.qzsmk.base.SystemManageContants;
import com.lanswon.qzsmk.dao.BusinessMapper;
import com.lanswon.qzsmk.dao.CardProdunctDefinitionMapper;
import com.lanswon.qzsmk.dao.CertMapper;
import com.lanswon.qzsmk.dao.OrgMapper;
import com.lanswon.qzsmk.dao.RoleMapper;
import com.lanswon.qzsmk.dao.RolePrivilegeMapper;
import com.lanswon.qzsmk.dao.SysPermissionMapper;
import com.lanswon.qzsmk.dao.UserMapper;
import com.lanswon.qzsmk.dao.UserOrgAdminMapper;
import com.lanswon.qzsmk.dao.UserRoleAdminMapper;
import com.lanswon.qzsmk.model.Business;
import com.lanswon.qzsmk.model.CardProdunctDefinition;
import com.lanswon.qzsmk.model.Cert;
import com.lanswon.qzsmk.model.Org;
import com.lanswon.qzsmk.model.Role;
import com.lanswon.qzsmk.model.RolePrivilege;
import com.lanswon.qzsmk.model.SysPermission;
import com.lanswon.qzsmk.model.User;
import com.lanswon.qzsmk.model.UserOrgAdmin;
import com.lanswon.qzsmk.model.UserRoleAdmin;
import com.lanswon.qzsmk.service.systemManageService.BranchManageService;
import com.lanswon.qzsmk.service.systemManageService.PrivilegeManageService;
import com.lanswon.qzsmk.service.systemManageService.RoleManageService;
import com.lanswon.qzsmk.service.systemManageService.TellerManageService;
import com.lanswon.qzsmk.util.SequenceNumberUtil;
import com.lanswon.qzsmk.vo.SaveOrUpdateBranchVo;
import com.lanswon.qzsmk.vo.SaveOrUpdateTellerVo;

/**
 * 系统初始化
 * @author sun
 *
 */
@Component
public class InitDataPrivilege  implements InitializingBean {

	@Autowired
	RequestMappingHandlerMapping rmhm;

	@Autowired
	PrivilegeManageService pms;
	
	@Autowired
	UserMapper um;
	
	@Autowired
	RoleMapper rm;
	
	@Autowired
	SysPermissionMapper spm;
	
	@Autowired
	RolePrivilegeMapper rpm;
	
	@Autowired
	TellerManageService tms;
	
	@Autowired
	RoleManageService rms;
	
	@Autowired
	UserRoleAdminMapper uram;
	
	@Autowired
	BranchManageService bms;
	
	@Autowired
	OrgMapper om;
	
	@Autowired
	UserOrgAdminMapper uoam;
	
	@Autowired
	CertMapper cem;
	
	@Autowired
	CardProdunctDefinitionMapper cpdm;
	
	@Autowired
	BusinessMapper bm;

	private static Logger logger = (Logger) LoggerFactory
			.getLogger(InitDataPrivilege.class);

	
	@SuppressWarnings("unchecked")
	@Override
	public void afterPropertiesSet() throws Exception {
		// 初始化 左侧菜单
		Long start = System.currentTimeMillis();
		//查询权限表所有数据
		List<SysPermission> listName = spm.queryAllName();
		if(listName.size()==0){
			SysPermission s = new SysPermission();
			s.setPrivilegeName("权限列表");
			listName.add(s);
		}
		Map<String,Object> map2=null;
		SysPermission s = new SysPermission();
		String name = "青州市市民卡卡片综合业务系统";
		s.setPrivilegeName(name);
		s.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		s.setPrivilegeTypeName(name);
		s.setParentid(null);
		s.setParentids(SystemManageContants.MENU_NODE_CUT);
		s.setSorting(0);
		s.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, s);
		s=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");

		SysPermission sp = new SysPermission();
		name = "卡片管理";
		sp.setPrivilegeName(name);
		sp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp.setPrivilegeTypeName(name);
		sp.setParentid(s.getPrivilegeId());
		sp.setParentids(s.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp.setSorting(0);
		sp.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp);
		sp=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");


		SysPermission sp_1 = new SysPermission();
		name = "制卡系统";
		sp_1.setPrivilegeName("制卡系统");
		sp_1.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp_1.setPrivilegeTypeName(name);
		sp_1.setParentid(s.getPrivilegeId());
		sp_1.setParentids(s.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp_1.setSorting(1);
		sp_1.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp_1);
		sp_1=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");

		SysPermission sp_2 = new SysPermission();
		name = "查询统计";
		sp_2.setPrivilegeName("查询统计");
		sp_2.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp_2.setPrivilegeTypeName(name);
		sp_2.setParentid(s.getPrivilegeId());
		sp_2.setParentids(s.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp_2.setSorting(2);
		sp_2.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp_2);
		sp_2=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");

		SysPermission sp_3 = new SysPermission();
		name = "系统管理";
		sp_3.setPrivilegeName("系统管理");
		sp_3.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp_3.setPrivilegeTypeName(name);
		sp_3.setParentid(s.getPrivilegeId());
		sp_3.setParentids(s.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp_3.setSorting(3);
		sp_3.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp_3);
		sp_3=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");


		SysPermission sp_4 = new SysPermission();
		name = "卡应用系统";
		sp_4.setPrivilegeName("卡应用系统");
		sp_4.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp_4.setPrivilegeTypeName(name);
		sp_4.setParentid(s.getPrivilegeId());
		sp_4.setParentids(s.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp_4.setSorting(4);
		sp_4.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp_4);
		sp_4=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");

		
		
		SysPermission sp_5 = new SysPermission();
		name = "库存系统";
		sp_5.setPrivilegeName("库存系统");
		sp_5.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp_5.setPrivilegeTypeName(name);
		sp_5.setParentid(s.getPrivilegeId());
		sp_5.setParentids(s.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp_5.setSorting(5);
		sp_5.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp_5);
		sp_5=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");


		// =====================卡片管理=================

		SysPermission sp1 = new SysPermission();
		name = "卡申请";
		sp1.setPrivilegeName("卡申请");
		sp1.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp1.setPrivilegeTypeName(name);
		sp1.setParentid(sp.getPrivilegeId());
		sp1.setParentids(sp.getParentids() + sp.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp1.setSorting(0);
		sp1.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp1);
		sp1=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");


		SysPermission sp2 = new SysPermission();
		name = "挂失解卦";
		sp2.setPrivilegeName("挂失解卦");
		sp2.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp2.setPrivilegeTypeName(name);
		sp2.setParentid(sp.getPrivilegeId());
		sp2.setParentids(sp.getParentids() + sp.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp2.setSorting(1);
		sp2.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp2);
		sp2=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");

		SysPermission sp3 = new SysPermission();
		name = "补卡换卡";
		sp3.setPrivilegeName("补卡换卡");
		sp3.setPrivilegeTypeName(name);
		sp3.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp3.setParentid(sp.getPrivilegeId());
		sp3.setParentids(sp.getParentids() + sp.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp3.setSorting(2);
		sp3.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp3);
		sp3=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");


		SysPermission sp4 = new SysPermission();
		name = "发卡售卡";
		sp4.setPrivilegeName(name);
		sp4.setPrivilegeTypeName(name);
		sp4.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp4.setParentid(sp.getPrivilegeId());
		sp4.setParentids(sp.getParentids() + sp.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp4.setSorting(3);
		sp4.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp4);
		sp4=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");


		SysPermission sp5 = new SysPermission();
		name = "注销";
		sp5.setPrivilegeName(name);
		sp5.setPrivilegeTypeName(name);
		sp5.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp5.setParentid(sp.getPrivilegeId());
		sp5.setParentids(sp.getParentids() + sp.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp5.setSorting(4);
		sp5.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp5);
		sp5=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");
		
		SysPermission sp15 = new SysPermission();
		name = "黑名单";
		sp15.setPrivilegeName(name);
		sp15.setPrivilegeTypeName(name);
		sp15.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp15.setParentid(sp.getPrivilegeId());
		sp15.setParentids(sp.getParentids() + sp.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp15.setSorting(5);
		sp15.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp15);
		sp15=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");


		// =======================制卡系统========================
		SysPermission sp6 = new SysPermission();
		name = "批量制卡";
		sp6.setPrivilegeName(name);
		sp6.setPrivilegeTypeName(name);
		sp6.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp6.setParentid(sp_1.getPrivilegeId());
		sp6.setParentids(sp_1.getParentids() + sp_1.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp6.setSorting(0);
		sp6.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp6);
		sp6=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");


		SysPermission sp7 = new SysPermission();
		name = "空白预制卡";
		sp7.setPrivilegeName(name);
		sp7.setPrivilegeTypeName(name);
		sp7.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp7.setParentid(sp_1.getPrivilegeId());
		sp7.setParentids(sp_1.getParentids() + sp_1.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp7.setSorting(1);
		sp7.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp7);
		sp7=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");

		
		SysPermission sp13 = new SysPermission();
		name = "银行文件录入";
		sp13.setPrivilegeName(name);
		sp13.setPrivilegeTypeName(name);
		sp13.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp13.setParentid(sp_1.getPrivilegeId());
		sp13.setParentids(sp_1.getParentids() + sp_1.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp13.setSorting(2);
		sp13.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp13);
		sp13=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");
		
		SysPermission sp20 = new SysPermission();
		name = "自主发卡卡号库";
		sp20.setPrivilegeName(name);
		sp20.setPrivilegeTypeName(name);
		sp20.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp20.setParentid(sp_1.getPrivilegeId());
		sp20.setParentids(sp_1.getParentids() + sp_1.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp20.setSorting(3);
		sp20.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp20);
		sp20=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");
		

		// =================查询统计======

		SysPermission sp8 = new SysPermission();
		name = "信息查询";
		sp8.setPrivilegeName(name);
		sp8.setPrivilegeTypeName(name);
		sp8.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp8.setParentid(sp_2.getPrivilegeId());
		sp8.setParentids(sp_2.getParentids() + sp_2.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp8.setSorting(0);
		sp8.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp8);
		sp8=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");


		// ==========系统管理

		SysPermission sp9 = new SysPermission();
		name = "卡产品管理";
		sp9.setPrivilegeName(name);
		sp9.setPrivilegeTypeName(name);
		sp9.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp9.setParentid(sp_3.getPrivilegeId());
		sp9.setParentids(sp_3.getParentids() + sp_3.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp9.setSorting(0);
		sp9.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp9);
		sp9=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");


		SysPermission sp10 = new SysPermission();
		name = "权限管理";
		sp10.setPrivilegeName(name);
		sp10.setPrivilegeTypeName(name);
		sp10.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp10.setParentid(sp_3.getPrivilegeId());
		sp10.setParentids(sp_3.getParentids() + sp_3.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp10.setSorting(1);
		sp10.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp10);
		sp10=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");
		
		SysPermission sp16 = new SysPermission();
		name = "个人信息";
		sp16.setPrivilegeName(name);
		sp16.setPrivilegeTypeName(name);
		sp16.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp16.setParentid(sp_3.getPrivilegeId());
		sp16.setParentids(sp_3.getParentids() + sp_3.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp16.setSorting(2);
		sp16.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp16);
		sp16=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");


		// =====================卡应用管理=
		
		
		

		SysPermission sp11 = new SysPermission();
		name = "应用管理";
		sp11.setPrivilegeName(name);
		sp11.setPrivilegeTypeName(name);
		sp11.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp11.setParentid(sp_4.getPrivilegeId());
		sp11.setParentids(sp_4.getParentids() + sp_4.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp11.setSorting(0);
		sp11.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp11);
		sp11=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");

		
		SysPermission sp12 = new SysPermission();
		name = "应用充值";
		sp12.setPrivilegeName(name);
		sp12.setPrivilegeTypeName(name);
		sp12.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp12.setParentid(sp_4.getPrivilegeId());
		sp12.setParentids(sp_4.getParentids() + sp_4.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp12.setSorting(1);
		sp12.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp12);
		sp12=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");


		// =====================库存管理=
		
		SysPermission sp19 = new SysPermission();
		name = "制卡返回文件导入";
		sp19.setPrivilegeName(name);
		sp19.setPrivilegeTypeName(name);
		sp19.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp19.setParentid(sp_5.getPrivilegeId());
		sp19.setParentids(sp_5.getParentids() + sp_5.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp19.setSorting(0);
		sp19.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp19);
		sp19=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");
		
		
		SysPermission sp14 = new SysPermission();
		name = "入库";
		sp14.setPrivilegeName(name);
		sp14.setPrivilegeTypeName(name);
		sp14.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp14.setParentid(sp_5.getPrivilegeId());
		sp14.setParentids(sp_5.getParentids() + sp_5.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp14.setSorting(1);
		sp14.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp14);
		sp14=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");
		
		SysPermission sp17 = new SysPermission();
		name = "出库";
		sp17.setPrivilegeName(name);
		sp17.setPrivilegeTypeName(name);
		sp17.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp17.setParentid(sp_5.getPrivilegeId());
		sp17.setParentids(sp_5.getParentids() + sp_5.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp17.setSorting(2);
		sp17.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp17);
		sp17=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");

		SysPermission sp18 = new SysPermission();
		name = "库存统计";
		sp18.setPrivilegeName(name);
		sp18.setPrivilegeTypeName(name);
		sp18.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
		sp18.setParentid(sp_5.getPrivilegeId());
		sp18.setParentids(sp_5.getParentids() + sp_5.getPrivilegeId() + SystemManageContants.MENU_NODE_CUT);
		sp18.setSorting(3);
		sp18.setAvailabel(SystemManageContants.STATUS_ENABLE);
		map2=pms.checkNameAndSave(listName, sp18);
		sp18=(SysPermission) map2.get("sy");
		listName=(List<SysPermission>) map2.get("list");
		
		

		Map<RequestMappingInfo, HandlerMethod> map = rmhm.getHandlerMethods();

		for (Entry<RequestMappingInfo, HandlerMethod> e : map.entrySet()) {
			RequestMappingInfo rmi = e.getKey();
			String name1 = rmi.getName();
			Set<String> set = rmi.getPatternsCondition().getPatterns();
			Iterator<String> it = set.iterator();

			while (it.hasNext()) {
				String uri = it.next();
				if (StringUtils.isNotEmpty(name1)) {
						boolean bb=false;
					for(SysPermission spn:listName){
						
						if(StringUtils.isNotEmpty(spn.getPrivilegeResource()) && spn.getPrivilegeResource().equals(uri) ){
							bb = true;
							break;
						}
					}
					if(!bb){
						
					
						SysPermission dp = new SysPermission();
						dp.setPrivilegeName(name1);
						dp.setPrivilegeResource(uri);
						dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_URL);

						if (name1.contains("applicationSingle:")) {
							dp.setParentid(sp1.getPrivilegeId());
							dp.setParentids(sp1.getParentids() + sp1.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("applicationSingle:index")) {
								dp.setPrivilegeTypeName("单笔申请");
								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(0);
							}

						} else if (name1.contains("applicationBatch:")) {
							dp.setParentid(sp1.getPrivilegeId());
							dp.setParentids(sp1.getParentids() + sp1.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);
							if (name1.contains("applicationBatch:index")) {
								dp.setPrivilegeTypeName("批量申请");
								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(1);
							}

						}else if (name1.contains("applicationBlankCardTask:")) {
							dp.setParentid(sp1.getPrivilegeId());
							dp.setParentids(sp1.getParentids() + sp1.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);
							if (name1.contains("applicationBlankCardTask:index")) {
								dp.setPrivilegeTypeName("预制卡申请");
								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(1);
							}

						} else if (name1.contains("loss:")) {
							dp.setParentid(sp2.getPrivilegeId());
							dp.setParentids(sp2.getParentids() + sp2.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("loss:index")) {
								dp.setPrivilegeTypeName("挂失");
								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(0);
							}
						} else if (name1.contains("relieveLoss:")) {
							dp.setParentid(sp2.getPrivilegeId());
							dp.setParentids(sp2.getParentids() + sp2.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("relieveLoss:index")) {
								dp.setPrivilegeTypeName("解挂");
								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(1);
							}
						} else if (name1.contains("reissueCard:")) {
							dp.setParentid(sp3.getPrivilegeId());
							dp.setParentids(sp3.getParentids() + sp3.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("reissueCard:index")) {
								dp.setPrivilegeTypeName("补卡");
								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(0);
							}
						} else if (name1.contains("exchangeCard:")) {
							dp.setParentid(sp3.getPrivilegeId());
							dp.setParentids(sp3.getParentids() + sp3.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("exchangeCard:index")) {
								dp.setPrivilegeTypeName("换卡");
								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(1);
							}
						} else if (name1.contains("issueCardBatch:")) {
							dp.setParentid(sp4.getPrivilegeId());
							dp.setParentids(sp4.getParentids() + sp4.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("issueCardBatch:index")) {
								dp.setPrivilegeTypeName("批量发卡");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(0);
							}
						} else if (name1.contains("issueCardSingle:")) {
							dp.setParentid(sp4.getPrivilegeId());
							dp.setParentids(sp4.getParentids() + sp4.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("issueCardSingle:index")) {
								dp.setPrivilegeTypeName("单笔发卡");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(1);
							}
						} else if (name1.contains("sellCard:")) {
							dp.setParentid(sp4.getPrivilegeId());
							dp.setParentids(sp4.getParentids() + sp4.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("sellCard:index")) {
								dp.setPrivilegeTypeName("售卡");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(2);
							}
						} else if (name1.contains("cancelCard:")) {
							dp.setParentid(sp5.getPrivilegeId());
							dp.setParentids(sp5.getParentids() + sp5.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("cancelCard:index")) {
								dp.setPrivilegeTypeName("注销");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(0);
							}
						}
						else if (name1.contains("cancelRefund:")) {
							dp.setParentid(sp5.getPrivilegeId());
							dp.setParentids(sp5.getParentids() + sp5.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("cancelRefund:index")) {
								dp.setPrivilegeTypeName("银行卡注销退款");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(1);
							}
						}
						
						else if (name1.contains("blackList:")) {
							dp.setParentid(sp15.getPrivilegeId());
							dp.setParentids(sp15.getParentids() + sp15.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("blackList:index")) {
								dp.setPrivilegeTypeName("黑名单管理");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(0);
							}
						} 
						
						else if (name1.contains("makeCardBatch:")) {
							dp.setParentid(sp6.getPrivilegeId());
							dp.setParentids(sp6.getParentids() + sp6.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("makeCardBatch:index")) {
								dp.setPrivilegeTypeName("批量制卡");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(0);
							}
						} else if (name1.contains("makeCardTaskExport:")) {
							dp.setParentid(sp6.getPrivilegeId());
							dp.setParentids(sp6.getParentids() + sp6.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("makeCardTaskExport:index")) {
								dp.setPrivilegeTypeName("批量制卡导出");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(1);
							}
						} else if (name1.contains("makeCardBlank:")) {
							dp.setParentid(sp7.getPrivilegeId());
							dp.setParentids(sp7.getParentids() + sp7.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("makeCardBlank:index")) {
								dp.setPrivilegeTypeName("空白卡制卡");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(2);
							}
						}else if (name1.contains("fileEntering:")) {
							dp.setParentid(sp13.getPrivilegeId());
							dp.setParentids(sp13.getParentids() + sp13.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("fileEntering:index")) {
								dp.setPrivilegeTypeName("文件录入");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(3);
							}
						} else if (name1.contains("generateCardNo:")) {
							dp.setParentid(sp20.getPrivilegeId());
							dp.setParentids(sp20.getParentids() + sp20.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("generateCardNo:index")) {
								dp.setPrivilegeTypeName("自主发卡卡号库");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(4);
							}
						}else if (name1.contains("querySingelInfo:")) {
							dp.setParentid(sp8.getPrivilegeId());
							dp.setParentids(sp8.getParentids() + sp8.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("querySingelInfo:index")) {
								dp.setPrivilegeTypeName("单笔申领查询");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(0);
							}
						} else if (name1.contains("queryBatchInfo:")) {
							dp.setParentid(sp8.getPrivilegeId());
							dp.setParentids(sp8.getParentids() + sp8.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("queryBatchInfo:index")) {
								dp.setPrivilegeTypeName("批量申领查询");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(1);
							}
						} else if (name1.contains("queryMakeCardTaskInfo:")) {
							dp.setParentid(sp8.getPrivilegeId());
							dp.setParentids(sp8.getParentids() + sp8.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("queryMakeCardTaskInfo:index")) {
								dp.setPrivilegeTypeName("制卡任务查询");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(2);
							}
						} else if (name1.contains("queryLossAndUnbindInfo:")) {
							dp.setParentid(sp8.getPrivilegeId());
							dp.setParentids(sp8.getParentids() + sp8.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("queryLossAndUnbindInfo:index")) {
								dp.setPrivilegeTypeName("挂失解挂业务查询");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(3);
							}
						} else if (name1.contains("queryChangeAndSupplementInfo:")) {
							dp.setParentid(sp8.getPrivilegeId());
							dp.setParentids(sp8.getParentids() + sp8.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("queryChangeAndSupplementInfo:index")) {
								dp.setPrivilegeTypeName("换卡补卡业务查询");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(4);
							}
						} else if (name1.contains("queryCardInfo:")) {
							dp.setParentid(sp8.getPrivilegeId());
							dp.setParentids(sp8.getParentids() + sp8.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("queryCardInfo:index")) {
								dp.setPrivilegeTypeName("卡状态信息查询");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(5);
							}
						} else if (name1.contains("queryCertInfo:")) {
							dp.setParentid(sp8.getPrivilegeId());
							dp.setParentids(sp8.getParentids() + sp8.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("queryCertInfo:index")) {
								dp.setPrivilegeTypeName("凭证查询");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(6);
							}
						} else if (name1.contains("queryHandleInfo:")) {
							dp.setParentid(sp8.getPrivilegeId());
							dp.setParentids(sp8.getParentids() + sp8.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("queryHandleInfo:index")) {
								dp.setPrivilegeTypeName("办理情况查询");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(7);
							}
						} else if (name1.contains("appOpenReg:")) {//应用开通停用
							dp.setParentid(sp11.getPrivilegeId());
							dp.setParentids(sp11.getParentids() + sp11.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("appOpenReg:index")) {
								dp.setPrivilegeTypeName("应用开通停用");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(0);
							}
						}  else if (name1.contains("appChargeDef:")) {//应用收费定义
							dp.setParentid(sp11.getPrivilegeId());
							dp.setParentids(sp11.getParentids() + sp11.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("appChargeDef:index")) {
								dp.setPrivilegeTypeName("应用收费定义");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(1);
							}
						} else if (name1.contains("applicationDefinition:")) {//应用类型定义
							dp.setParentid(sp11.getPrivilegeId());
							dp.setParentids(sp11.getParentids() + sp11.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("applicationDefinition:index")) {
								dp.setPrivilegeTypeName("应用类型定义");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(2);
							}
						}else if (name1.contains("appRecharge:")) {//应用充值
							dp.setParentid(sp12.getPrivilegeId());
							dp.setParentids(sp12.getParentids() + sp12.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("appRecharge:index")) {
								dp.setPrivilegeTypeName("应用充值");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(0);
							}
						}else if (name1.contains("balanceTransfer:")) {//应用开通停用
							dp.setParentid(sp12.getPrivilegeId());
							dp.setParentids(sp12.getParentids() + sp12.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("balanceTransfer:index")) {
								dp.setPrivilegeTypeName("余额转移");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(1);
							}
						}else if (name1.contains("cardProductDefinition:")) {
							dp.setParentid(sp9.getPrivilegeId());
							dp.setParentids(sp9.getParentids() + sp9.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("cardProductDefinition:index")) {
								dp.setPrivilegeTypeName("卡产品定义");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(0);
							}
						}else if (name1.contains("cardBusinessParameters:")) {
							dp.setParentid(sp9.getPrivilegeId());
							dp.setParentids(sp9.getParentids() + sp9.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("cardBusinessParameters:index")) {
								dp.setPrivilegeTypeName("卡业务参数");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(0);
							}
						}else if (name1.contains("psamCardManage:")) {
							dp.setParentid(sp9.getPrivilegeId());
							dp.setParentids(sp9.getParentids() + sp9.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("psamCardManage:index")) {
								dp.setPrivilegeTypeName("psam管理");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(0);
							}
						}else if (name1.contains("tellerManage:")) {
							dp.setParentid(sp10.getPrivilegeId());
							dp.setParentids(sp10.getParentids() + sp10.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("tellerManage:index")) {
								dp.setPrivilegeTypeName("柜员管理");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(0);
							}
						}else if (name1.contains("branchManage:")) {
							dp.setParentid(sp10.getPrivilegeId());
							dp.setParentids(sp10.getParentids() + sp10.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("branchManage:index")) {
								dp.setPrivilegeTypeName("网点管理");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(0);
							}
						}else if (name1.contains("roleManage:")) {
							dp.setParentid(sp10.getPrivilegeId());
							dp.setParentids(sp10.getParentids() + sp10.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("roleManage:index")) {
								dp.setPrivilegeTypeName("角色管理");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(0);
							}
						}else if (name1.contains("tellerAuth:")) {
							dp.setParentid(sp10.getPrivilegeId());
							dp.setParentids(sp10.getParentids() + sp10.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("tellerAuth:index")) {
								dp.setPrivilegeTypeName("柜员授权");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(0);
							}
							
						}else if (name1.contains("personalInfo:")) {
							dp.setParentid(sp16.getPrivilegeId());
							dp.setParentids(sp16.getParentids() + sp16.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("personalInfo:index")) {
								dp.setPrivilegeTypeName("个人信息修改");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(0);
							}
							
						}else if (name1.contains("inventoryIncmoingMagOfCenter:")) {
							dp.setParentid(sp14.getPrivilegeId());
							dp.setParentids(sp14.getParentids() + sp14.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("inventoryIncmoingMagOfCenter:index")) {
								dp.setPrivilegeTypeName("制卡返回中心库入库");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(0);
							}
						}else if (name1.contains("inventoryIncomingMagOfBranch:")) {
							dp.setParentid(sp14.getPrivilegeId());
							dp.setParentids(sp14.getParentids() + sp14.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("inventoryIncomingMagOfBranch:index")) {
								dp.setPrivilegeTypeName("网点接收配送入库");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(1);
							}
						}else if (name1.contains("inventoryMagOfReturningByEmp:")) {
							dp.setParentid(sp14.getPrivilegeId());
							dp.setParentids(sp14.getParentids() + sp14.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("inventoryMagOfReturningByEmp:index")) {
								dp.setPrivilegeTypeName("柜员归还卡片");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(2);
							}
						}else if (name1.contains("inventoryMagOfReceiveBFByCenter:")) {
							dp.setParentid(sp14.getPrivilegeId());
							dp.setParentids(sp14.getParentids() + sp14.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("inventoryMagOfReceiveBFByCenter:index")) {
								dp.setPrivilegeTypeName("空白卡/成品卡上缴接收入库");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(3);
							}
						}else if (name1.contains("inventoryMagOfReceiveRejectCardByCenter:")) {
							dp.setParentid(sp14.getPrivilegeId());
							dp.setParentids(sp14.getParentids() + sp14.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("inventoryMagOfReceiveRejectCardByCenter:index")) {
								dp.setPrivilegeTypeName("废卡上缴接收入库");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(4);
							}
						}else if (name1.contains("inventoryMagOfSurplus:")) {
							dp.setParentid(sp14.getPrivilegeId());
							dp.setParentids(sp14.getParentids() + sp14.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("inventoryMagOfSurplus:index")) {
								dp.setPrivilegeTypeName("盘盈入库");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(5);
							}
						}else if (name1.contains("inventoryMagOfIncomingCancel:")) {
							dp.setParentid(sp14.getPrivilegeId());
							dp.setParentids(sp14.getParentids() + sp14.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("inventoryMagOfIncomingCancel:index")) {
								dp.setPrivilegeTypeName("入库撤销");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(6);
							}
						}else if (name1.contains("inventoryDistributionMagOfCenter:")) {
							dp.setParentid(sp17.getPrivilegeId());
							dp.setParentids(sp17.getParentids() + sp17.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("inventoryDistributionMagOfCenter:index")) {
								dp.setPrivilegeTypeName("中心库配送出库");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(0);
							}
						}else if (name1.contains("inventoryMagOfBlankRequiredByEmp:")) {
							dp.setParentid(sp17.getPrivilegeId());
							dp.setParentids(sp17.getParentids() + sp17.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("inventoryMagOfBlankRequiredByEmp:index")) {
								dp.setPrivilegeTypeName("柜员领用空白卡出库");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(1);
							}
						}else if (name1.contains("inventoryMagOfBatchRequiredByEmp:")) {
							dp.setParentid(sp17.getPrivilegeId());
							dp.setParentids(sp17.getParentids() + sp17.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("inventoryMagOfBatchRequiredByEmp:index")) {
								dp.setPrivilegeTypeName("柜员领用批量卡出库");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(2);
							}
						}else if (name1.contains("inventoryMagOfBlankCardTurnInByBranch:")) {
							dp.setParentid(sp17.getPrivilegeId());
							dp.setParentids(sp17.getParentids() + sp17.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("inventoryMagOfBlankCardTurnInByBranch:index")) {
								dp.setPrivilegeTypeName("空白卡/成品卡上缴配送出库");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(3);
							}
						}else if (name1.contains("inventoryMagOfRejectCardTurnInByBranch:")) {
							dp.setParentid(sp17.getPrivilegeId());
							dp.setParentids(sp17.getParentids() + sp17.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("inventoryMagOfRejectCardTurnInByBranch:index")) {
								dp.setPrivilegeTypeName("废卡上缴配送出库");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(4);
							}
						}else if (name1.contains("inventoryMagOfDishDeficient:")) {
							dp.setParentid(sp17.getPrivilegeId());
							dp.setParentids(sp17.getParentids() + sp17.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("inventoryMagOfDishDeficient:index")) {
								dp.setPrivilegeTypeName("盘亏出库");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(5);
							}
						}else if (name1.contains("inventoryMagOfOutGoingCancel:")) {
							dp.setParentid(sp17.getPrivilegeId());
							dp.setParentids(sp17.getParentids() + sp17.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("inventoryMagOfOutGoingCancel:index")) {
								dp.setPrivilegeTypeName("出库撤销");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(6);
							}
						}else if (name1.contains("inventoryQueryOfIncomingAndOutRecords:")) {
							dp.setParentid(sp18.getPrivilegeId());
							dp.setParentids(sp18.getParentids() + sp18.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("inventoryQueryOfIncomingAndOutRecords:index")) {
								dp.setPrivilegeTypeName("出入库清单查询并打印");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(0);
							}
						}else if (name1.contains("inventoryQueryOfAmountAtBranch:")) {
							dp.setParentid(sp18.getPrivilegeId());
							dp.setParentids(sp18.getParentids() + sp18.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("inventoryQueryOfAmountAtBranch:index")) {
								dp.setPrivilegeTypeName("库存查询");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(1);
							}
						}else if (name1.contains("inventoryQueryOfIncomingAndOutgoing:")) {
							dp.setParentid(sp18.getPrivilegeId());
							dp.setParentids(sp18.getParentids() + sp18.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("inventoryQueryOfIncomingAndOutgoing:index")) {
								dp.setPrivilegeTypeName("出入库查询");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(2);
							}
						}else if (name1.contains("inventoryQueryOfRequestAndReturnReg:")) {
							dp.setParentid(sp18.getPrivilegeId());
							dp.setParentids(sp18.getParentids() + sp18.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("inventoryQueryOfRequestAndReturnReg:index")) {
								dp.setPrivilegeTypeName("柜员领用归还查询");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(3);
							}
						}else if (name1.contains("inventoryMagOfReturnFileImport:")) {
							dp.setParentid(sp19.getPrivilegeId());
							dp.setParentids(sp19.getParentids() + sp19.getPrivilegeId()
									+ SystemManageContants.MENU_NODE_CUT);

							if (name1.contains("inventoryMagOfReturnFileImport:index")) {
								dp.setPrivilegeTypeName("制卡返回文件导入");

								dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_MENU);
								dp.setSorting(0);
							}
						}	
						else {
							dp.setPrivilegeType(SystemManageContants.PERMISSIONS_TYPE_URL);

						}

						if (name1.indexOf(",") > 0) {
							String percode = name1.substring(name1.indexOf(",") + 1);
							dp.setPercode(percode);
						}

						dp.setAvailabel(SystemManageContants.STATUS_ENABLE);
						pms.saveDataPrivilege_1(dp);
						
						listName.add(dp);
					}

				}
			}

		}
		
		logger.debug("###########---初始化超级管理员---###########");
		
		
		
		//初始化超管
		User u = um.queryUserByLoginName("admin");
		if(u == null){
			SaveOrUpdateTellerVo uu = new SaveOrUpdateTellerVo("超级管理员","admin","123456");
			u = new User();
			 tms.addTeller(uu);
				u.setUserId(uu.getUserId());
		}
		
		SaveOrUpdateBranchVo b = new SaveOrUpdateBranchVo();
		b.setAddress("青州海岱路路9999号");
		b.setOrgName("青州市民卡总公司");
		b.setPrincipal(u.getLoginName());
		b.setLinkMan(u.getLoginName());
		b.setTelephone(u.getTelephone());
		b.setPostcode("123456");
		b.setProperty(SystemManageContants.ORG_PROPERTY_GOV);

		b.setEmail("xxxxxxxx@qq.com");
		b.setStatus(SystemManageContants.STATUS_ENABLE);
		b.setApplyDate(new Date());
		b.setActiveDate(new Date());
		b.setStreet("370781001000");
		b.setLeadName(u.getUserName());
		b.setLeadPaperType(u.getPaperType());
		b.setLeadPaperNo(u.getPaperNo());
		int[] ids = new int[2];
		if(om.queryCountByName(b.getOrgName())==0){
			ids = bms.addBranch(b);
		}else{
			Org  oo = om.queryOrgByOrgName(b.getOrgName());
			int orgById = oo.getOrgId();
			ids = new int[]{orgById,oo.getOrgNo()};
		}
		
		UserOrgAdmin  uoa = new UserOrgAdmin();
		uoa.setOrgId(ids[0]);
		uoa.setUserId(u.getUserId());
		if(uoam.queryUserOrgAdminByUserId(u.getUserId()) == null){
			uoam.insert(uoa);
		}
		
		tms.modifyTeller_init(u.getUserId(), String.valueOf(ids[1]));
		
		
		
		Role r = rm.queryRoleByRoleName("超级管理员");
		if(r == null){
			r = new Role(1,"超级管理员","专属admin");
			rms.addRole(r);
		}
		
		UserRoleAdmin ura1 = new UserRoleAdmin(r.getRoleId(), r.getSysId(), u.getUserId());
		UserRoleAdmin ura = uram.queryUserRoleAdminByUserRoleAdmin(ura1);
		if(ura == null){
			uram.insert(ura1);
		}
		
		//所有权限
		List<SysPermission> l = spm.queryAllSysPermissionPerCode();
		List<RolePrivilege> lr = rpm.queryAll();
		List<RolePrivilege> lll  =  new ArrayList<>();
		if(lr.size() == 0){
			for(SysPermission aa:l){
				RolePrivilege rp = new RolePrivilege(aa.getPrivilegeId(),r.getSysId(),r.getRoleId());
//				rpm.insert(rp);
				lll.add(rp);
				
			}
		}else{
			for(SysPermission aa:l){
				RolePrivilege rp = new RolePrivilege(aa.getPrivilegeId(),r.getSysId(),r.getRoleId());
//				RolePrivilege rp1 = rpm.queryRolePrivilegeByRolePrivilege(rp);
				boolean bb=true;
				for(RolePrivilege rp1:lr){
					if(rp1.getPrivilegeId().intValue()==rp.getPrivilegeId().intValue()&& rp1.getSysId().intValue()==rp.getSysId().intValue() && rp1.getRoleId().intValue()==rp.getRoleId().intValue()){
//						rpm.insert(rp);
						bb=false;
						break;
					}
					
				}
				if(bb){
					lll.add(rp);
				}
				
			}
		}
		logger.debug("lll.count[{}]",lll.size());
		//baocun
		if(lll.size()>0)
		rms.batchInsert(lll);
		//初始化凭证编号
		String now =new SimpleDateFormat("yyyy-MM-dd").format(new Date());
		Cert cert=cem.queryCertByCrtDate(now);
		if(cert==null){
			SequenceNumberUtil.setCertSeq(0);
		}else{
			int certSeq=Integer.parseInt(cert.getCertNo().substring(8));
			SequenceNumberUtil.setCertSeq(certSeq);
		}
		String date=new SimpleDateFormat("yyMMdd").format(new Date());
		Business business=bm.queryLastBussiness(date);
		if(business==null){
			SequenceNumberUtil.setBusSeq(0);
		}else{
			int busSeq=Integer.parseInt(business.getBusinessNo().substring(6));
			SequenceNumberUtil.setBusSeq(busSeq);
		}
		String copBankNo=CardContants.CARD_PUBLISHER_CODE_JS;
		CardProdunctDefinition cpd= cpdm.queryCardProdunctDefinitionByCardPublisherCode(copBankNo).get(0);
		CardContants.CARD_P_CODE_JS=cpd.getCardpCode();
		copBankNo=CardContants.CARD_PUBLISHER_CODE_WF;
		cpd=cpdm.queryCardProdunctDefinitionByCardPublisherCode(copBankNo).get(0);
		CardContants.CARD_P_CODE_WF=cpd.getCardpCode();
		logger.debug("####初始化时间###-----{}秒",(System.currentTimeMillis()-start)/1000);

	}
	
	


}
